from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from time import  sleep
# 创建浏览器驱动对象
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome()
# 加载web页面
driver.get("http://121.43.169.97:8848/pageA.html")
# 放大浏览器
driver.maximize_window()

# 需求：打开‘注册A.html’页面，完成以下操作
# 1). 填写注册信息
driver.find_element_by_css_selector("#userA").send_keys("admin")

# 2). 截图保存
# 调用截屏方法
# driver.get_screenshot_as_file("../img/admin.png")
# 动态获取文件名称：使用时间戳
# driver.get_screenshot_as_file("../img/%s.png" %(time.strftime("%Y_%m_%d_%H_%M_%S")))
driver.get_screenshot_as_file("../img/{}.png".format(time.strftime("%Y_%m_%d_%H_%M_%S")))









sleep(3)
driver.quit()